import {Injectable,OnInit} from '@angular/core';

import {Http, Response} from '@angular/http';
import { Observable } from 'rxjs/Rx';

import {User,Picture} from './user';
import {SignComponent} from './sign.component';


@Injectable()
export class Service implements OnInit{

 loading:boolean;
 data:any;
constructor(private http: Http) {}
  ngOnInit() {}
 //通过get获取信息
  userGet(user:User){
    this.loading = true;
    this.http.get('../assets/data/picture.json').subscribe((res:Response) =>{
      this.data = res.json().data;
      this.loading = false;
    })
  }

  userPost(picture:Picture){
     this.loading = true;
     this.http.post('../assets/data/picture.json',
     JSON.stringify({
      pictrueid: ""
     })
   ).subscribe((res:Response) =>{
       this.data = res.json();
       this.loading = false;
     })
  }

}
